<?php
/*
用户设置页
set 配置设置
	
get 获取设置
*/


include '../include/init.php';







$uid=$_POST['u'];



$type=$_POST['t'];

$mod=$_POST['m'];

$cfg=new configModel();


if($type=='set')
{
	if($mod=="one")
	{
		$setval=$_POST['v'];
		$setname=$_POST['n'];
		if($cfg->set($uid,$setname,$setval))
		{
			echo 'ok';
		}
		else
		{
			echo 'no';
		}
	}
	else if($mod=="part")
	{
		$setval=$_POST['v'];
		
		//$setval=explode(',',$setval);	
		
		/*将指定的字符串转换为键值对数组*/
		$setval = str_replace(array('-',','),array('"=>"','","'),'array("'.$setval.'")');
		eval("\$setval"." = $setval;");

		if($cfg->setpart($setval,$uid))
		{
			echo 'ok';
		}
		else
		{
			echo 'no';
		}
	}
	exit;
}
else if($type=='get')
{
	
	if($mod=='all')
	{
		echo json_encode($cfg->getall($uid));
		exit;
	}
	else
	{
		$cfgname=$_POST['n'];
	}

}
